﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YBApproval.Model;
using YBApproval.IDAL;
using YBApproval.BLL;

namespace YBApproval
{
    public partial class About : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.UCForm1.FormId = 1;
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string errorMsg;
            List<InstanceValue> valueList = this.UCForm1.GetValues(out errorMsg);
            if (!string.IsNullOrEmpty(errorMsg))
            {
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "input_validate", "alert('" + errorMsg + "');", true);
            }
            else
            {
                this.txtValues.Value = "";
                foreach (InstanceValue instValue in valueList)
                {
                    this.txtValues.Value += instValue.FieldId + " : " + instValue.Value + System.Environment.NewLine;
                }
                foreach (InstanceValue instValue in valueList)
                {
                    this.txtValues.Value += instValue.FieldId + " : " + instValue.Text + System.Environment.NewLine;
                }
            }
        }
    }
}
